<template>
    <div class="main_box" style="padding:10px">
        <div class="add_wrap">
            <el-form label-width="200px" v-if="dataInfo">
                <div class="tit">
                    <h2>基础信息</h2>
                    <el-button type="success" plain size="small" icon="fa fa-mail-forward"
                        @click="returnList">返回</el-button>
                </div>
                <el-row>
                    <el-form-item label="头像:" v-if="dataInfo.avatar">
                        <el-image :src="dataInfo.avatar" fit="cover"></el-image>
                    </el-form-item>
                    <el-form-item label="真实姓名:">
                        <span>{{ dataInfo.fullName }}</span>
                    </el-form-item>
                    <el-form-item label="性别:">
                        <span>{{ dataInfo.sex == 1 ? "男" : "女" }}</span>
                    </el-form-item>
                    <el-form-item label="用户编码:">
                        <span>{{ dataInfo.userCode }}</span>
                    </el-form-item>
                    <el-form-item label="用户名:">
                        <span>{{ dataInfo.userName }}</span>
                    </el-form-item>
                    <el-form-item label="昵称:">
                        <span>{{ dataInfo.nickName }}</span>
                    </el-form-item>
                    <el-form-item label="邮箱:">
                        <span>{{ dataInfo.email }}</span>
                    </el-form-item>
                    <el-form-item label="手机号:">
                        <span>{{ dataInfo.phone }}</span>
                    </el-form-item>
                    <el-form-item label="商户:">
                        <span>{{ dataInfo.businessName }}</span>
                    </el-form-item>
                    <el-form-item label="评分:">
                        <span>{{ dataInfo.grade }}</span>
                    </el-form-item>
                    <el-form-item label="备注:">
                        <span>{{ dataInfo.remark }}</span>
                    </el-form-item>
                    <el-form-item label="创建人:">
                        <span>{{ dataInfo.createUserName }}</span>
                    </el-form-item>
                    <el-form-item label="创建时间:">
                        <span>{{ dataInfo.createDate }}</span>
                    </el-form-item>
                    <el-form-item label="修改人:">
                        <span>{{ dataInfo.modifyUserName }}</span>
                    </el-form-item>
                    <el-form-item label="修改时间:">
                        <span>{{ dataInfo.modifyDate }}</span>
                    </el-form-item>

                    <el-form-item label="推广码:" v-if="dataInfo.promoteWxAppUrl">
                        <el-image :src="dataInfo.promoteWxAppUrl" fit="cover"></el-image>
                    </el-form-item>
                </el-row>
                <!-- <div class="tit">
                    <h2>商户服务范围</h2>

                </div>
                <el-row>
                    <el-table :data="businessVillages" style="width:fit-content">
                        <el-table-column type="index" label="序号" align="center" width="100px">
                        </el-table-column>
                        <el-table-column label="地区" prop="address" width="300" align="center">

                        </el-table-column>
                        <el-table-column label="小区" prop="villageName" align="center" width="250">

                        </el-table-column>
                    </el-table>
                </el-row> -->
                <div class="tit">
                    <h2>服务范围信息</h2>
                </div>
                <el-row>
                    <el-table :data="list" border style="width:max-content">
                        <el-table-column type="index" label="序号" align="center" width="100px">
                        </el-table-column>
                        <el-table-column prop="address" label="地区" align="center" width="300px">
                            <template slot-scope="scope">
                                <div>
                                    {{ scope.row.provinceName }}{{ scope.row.cityName }}{{ scope.row.areaName }}{{
                                        scope.row.streetName }}
                                </div>
                            </template>
                        </el-table-column>
                        <el-table-column prop="villageName" label="小区" align="center" width="250px">
                        </el-table-column>
                        <!--<el-table-column prop="linkName" label="联系人" align="center" width="150px">
              </el-table-column>
              <el-table-column prop="linkPhone" label="联系电话" align="center" width="200px">
              </el-table-column>-->
                    </el-table>
                </el-row>
            </el-form>
        </div>
    </div>
</template>

<script>
import SalesmanApi from '@/api/business/salesman';
// import BusinessVillageApi from "@/api/business/businessVillage"
export default {
    data() {
        return {
            dataInfo: {},
            businessList: [],
            list: [],
            businessVillages: [],
            departNames: "",
        };
    },
    computed: {},
    mounted() {
        this.getData()
    },
    methods: {
        getData() {
            SalesmanApi.getSalesmanInfo({ id: this.$route.query.id }).then(res => {
                this.dataInfo = res.data
                this.list = res.data.list
                // this.getBusinessVillages()
            })
        },
        // async getBusinessVillages() {
        //     const { businessId } = this.dataInfo
        //     let res = []
        //     if (businessId) {
        //         res = await BusinessVillageApi.listByBusinessId({ businessId })
        //         res = (res.data || []).filter(item => item.type == 2 || item.type == 4)
        //         res = res.reduce((a, b) => a.concat(b.villages), [])
        //         res.forEach(item => {
        //             item.address = (item.provinceName || "") + (item.cityName || "") + (item.areaName || "") + (item.streetName || "")
        //             // item.address
        //         })

        //     }
        //     this.businessVillages = res
        // },
        returnList() {
            this.$store.dispatch('delView', this.$route);
            this.$router.back()
        }
    },

}

</script>
<style lang="scss" scoped>
@import "@/assets/css/views/add.scss";
</style>
